home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9415 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.7 KB  |  57 lines

  1. Path: jaxnet.jaxnet.com!jax!garyg
  2. From: garyg@jax.jaxnet.com (Gary M. Greenberg)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Newbie doesn't understand compiler error
  5. Date: 10 Mar 1996 15:28:33 GMT
  6. Organization: Southeast Network Services, Inc.
  7. Message-ID: <4husf1$eui@jaxnet.jaxnet.com>
  8. References: <Pine.SUN.3.91.960301153010.11258B-100000@pioneer.uspto.gov>
  9. NNTP-Posting-Host: jax.jaxnet.com
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Max Schubert (schubert@pioneer.uspto.gov) wrote:
  13. : I have just started to work with two different learning C books.  They 
  14. : both have programs to copy and compile as I go along.  Twice I have 
  15. : received this error from cc when attempting to compile two separate
  16.               ^^^^
  17. : programs on SunOS 4.1.2:
  18.         ^^^^^^^
  19.  
  20. Those 2 facts (cc && SunOS 4.1.2) indicate that your compiler is pre-ANSI C.
  21. Therefore, programs written with this compiler will require K & R style
  22. function definitions.
  23.  
  24. : #include <stdio.h>
  25.  
  26. : void do_heading(char *filename);
  27.  
  28. : int line, page;
  29.  
  30. : main( int argv, char *argc[] )  <<- Compiler states "Syntax error at or near
  31. : {                    word type char."
  32.  
  33. Two points:
  34.     1. argc and argv are typically the other way. Argc infers Count, 
  35.        and argv infers Vector into the Array of argument strings.
  36.        It will work as written, but may lead to confusion.
  37.     2. For your compiler, use:
  38.  
  39. int main(argc,argv)
  40. int argc,
  41. char **argv;
  42. {
  43.     /* rest of code */
  44. }
  45.  
  46. : Do I need to update my compiler?
  47.  
  48. Probably in your best interest; the pre-ANSI C compiler supplied with SunOS
  49. lacks other features of the ANSI C standard.
  50.  
  51. C'ya,
  52.  
  53. gary    /* the Sorcerer's Apprentice */
  54.  
  55. The Communications Decency Act is proof:
  56.     (((U.S. Congress && Executive)==(Collective Moron))==1)
  57.